package com.rs.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rs.dao.ZhClassesMapper;
import com.rs.dao.ZhEmploymentMapper;
import com.rs.model.CommonResult;
import com.rs.model.ZhClasses;
import com.rs.model.ZhEmployment;
import com.rs.service.ZhEmploymentService;

@Service
@Transactional
public class ZhEmploymentServiceImpl implements ZhEmploymentService {
	
	@Autowired
	ZhEmploymentMapper zhEmpolymentMapper;
	
	@Autowired
	ZhClassesMapper zhClassesMapper;
	
	static final Integer NUMBER=10;

	@Override
	public CommonResult<Integer> updateZhEmployment(ZhEmployment zhEmployment) {
		// TODO Auto-generated method stub
		int state = zhEmpolymentMapper.updateZhEmployment(zhEmployment);
		if(state==0){
			return new CommonResult<Integer>(0,"修改失败",state);
		}
		return new CommonResult<Integer>(200,"修改成功",state);
	}

	@Override
	public CommonResult<Integer> deleteZhEmployment(Integer emUid) {
		// TODO Auto-generated method stub
		int state = zhEmpolymentMapper.deleteZhEmployment(emUid);
		if(state==0){
			return new CommonResult<Integer>(0,"删除失败",state);
		}
		return new CommonResult<Integer>(200,"删除成功",state);
	}

	@Override
	public CommonResult<ZhEmployment> selectZhEmployment(Integer uid) {
		// TODO Auto-generated method stub
		ZhEmployment state = zhEmpolymentMapper.selectZhEmployment(uid);
		if(state==null){
			return new CommonResult<ZhEmployment>(0,"查询失败",state);
		}
		return new CommonResult<ZhEmployment>(200,"查询成功",state);
	}

	@Override
	public Page<ZhEmployment> selectZhEmployments(ZhEmployment zhEmployment) {
		// TODO Auto-generated method stub
		PageHelper.startPage(zhEmployment.getPageNum(),NUMBER);
		Page<ZhEmployment> page = zhEmpolymentMapper.selectZhEmployments(zhEmployment);
		return page;
	}

	@Override
	public CommonResult<Integer> addZhEmployment(ZhEmployment zhEmployment) {
		// TODO Auto-generated method stub
		Integer state = zhEmpolymentMapper.addZhEmployment(zhEmployment);
		if(state==0){
			return new CommonResult<Integer>(0,"添加失败",state);
		}
		return new CommonResult<Integer>(200,"添加成功",state);
	}

	@Override
	public Page<ZhClasses> graduationZhClassess(Integer pageNum) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum,NUMBER);
		return zhClassesMapper.graduationZhClassess();
	}

	@Override
	public Page<ZhEmployment> listZhEmployments(Integer pageNum) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum,NUMBER);
		return zhEmpolymentMapper.listZhEmployments();
	}

	@Override
	public Integer deleteZhEmploymentId(Integer emid) {
		// TODO Auto-generated method stub
		return zhEmpolymentMapper.deleteZhEmploymentId(emid);
	}

	@Override
	public ZhEmployment zhEmploymentId(Integer emId) {
		// TODO Auto-generated method stub
		return zhEmpolymentMapper.zhEmploymentId(emId);
	}

}
